#pragma once

#define KEYDOWN(vk_code)  ((GetAsyncKeyState(vk_code) & 0x8000) ? true : false)
#define KEYUP(vk_code)  ((GetAsyncKeyState(vk_code) & 0x8000) ? false : true)

class Input
{
public:
	static bool KeysDown(int key)
	{
		static unsigned long xenimusPid = NULL;
		if (xenimusPid == NULL) {
			HWND xenimusHandle = FindWindow("Direct3DWindowClass", "Xenimus");
			GetWindowThreadProcessId(xenimusHandle, &xenimusPid);
		}
		
		unsigned long foregroundPid = NULL;
		GetWindowThreadProcessId(GetForegroundWindow(), &foregroundPid);

		if(xenimusPid == foregroundPid) {
			if (isalpha( key))
				return KEYDOWN(toupper(key));
			else
				return KEYDOWN(key);
		} else {
			return false;
		}
	}
};
